<?php
namespace app\admin\controller;
use app\admin\model\IndexTableModel;
use app\admin\model\JoinTableModel;
use think\Db;
use think\Request;
use app\common\model\User;
use app\common\model\UserLevel;
use app\common\validate\UserValidate;

require_once (__DIR__.'/../../../vendor/ReidsLock.class.php');
class FaboardController extends Controller
{

    /**
     * 数据看板
     * User:@hang
     */
    public function index(Request $request)
    {
        $param = $request->param();
        $table_name = '';
        $qd = '';
        $start_time = '';
        $end_time = '';
        $whehe = array();
        if (isset($param['qd']) && !empty($param['qd'])) {
            $qd = $param['qd'];
            switch($param['qd']){
                case '快手': $table_name = 'z_tuiguang_monitoring_ks';break;
                case '抖音': $table_name = 'z_tuiguang_monitoring_dy';break;
                case 'vivo': $table_name = 'z_tuiguang_monitoring_vivo';break;
                case 'oppo': $table_name = 'z_tuiguang_monitoring_oppo';break;
                case '小米': $table_name = 'z_tuiguang_monitoring_xiaomi';break;
            }
        }
        if (isset($param['daytime']) && !empty($param['daytime'])) {
            $start_time = strtotime($param['daytime']);
            $end_time = $start_time + 86399;
        }
        //收集看板数据
        $data = $this->getdataboard($table_name,$qd,$start_time,$end_time);
//        return json($data);
        //关键词，排序等赋值
        $this->assign($request->get());
        $this->assign([
            'data'  => $data,
        ]);
        return $this->fetch();
    }


    /**
     * 新增统计
     * User:@hang
     */
    public function getdataboard($table_name,$qd,$start_time,$end_time)
    {
        //开始和结束时间
        if(empty($start_time) || empty($end_time)){
            $start_time = strtotime(date('Y-m-d').'00:00:00');//当日开始时间
            $end_time = $start_time + 86399;//当日结束时间
            $last_start_time = $start_time - 86400;//昨日开始时间
            $last_end_time = $end_time - 86400;//昨日结束时间
            $day_word = '当日';
            $last_day_word = '昨日';
        }else{
            $last_start_time = $start_time - 86400;//昨日开始时间
            $last_end_time = $end_time - 86400;//昨日结束时间
            $day_word = date('Y-m-d',$start_time).' ';
            $last_day_word = date('Y-m-d',$last_start_time).' ';
        }
        $start_time_hm = $start_time * 1000;//毫秒
        $end_time_hm = $end_time * 1000;//毫秒
        $last_start_time_hm = $last_start_time * 1000;//毫秒
        $last_end_time_hm = $last_end_time * 1000;//毫秒

        $wheres = '';$wherea = '';
        if(!empty($qd)){
            $wheres = " and me_qd = '{$qd}'";
            $wherea = " and a.me_qd = '{$qd}'";
        }

        $infos = [];
        //平台在线男/女数
        $ptboyzx = Db::table('fa_member')->where("me_zx = 0 and me_sex = 1")->count('member_id');
        $ptgirlzx = Db::table('fa_member')->where("me_zx = 0 and me_sex = 2")->count('member_id');
        $infos[0]['word'] = '平台在线男 / 女数';
        $infos[0]['values'] = "男 {$ptboyzx} 人 / 女 {$ptgirlzx} 人";
        $infos[0]['color'] = "green";

        //当日注册用户
        $drzcyh_where = "me_sex != 0 and me_add_time >= $start_time and me_add_time <= $end_time".$wheres;
        $drzcyh = Db::table('fa_member')->where($drzcyh_where)->count('member_id');
        $infos[1]['word'] = $day_word.'注册用户';
        $infos[1]['values'] = "{$drzcyh} 人";
        $infos[1]['color'] = "red";

        //当日注册男/女数
        $drzcboyyh_where = "me_sex = 1 and me_add_time >= $start_time and me_add_time <= $end_time".$wheres;
        $drzcboyyh = Db::table('fa_member')->where($drzcboyyh_where)->count('member_id');
        $drzcgirlyh_where = "me_sex = 2 and me_add_time >= $start_time and me_add_time <= $end_time".$wheres;
        $drzcgirlyh = Db::table('fa_member')->where($drzcgirlyh_where)->count('member_id');
        $infos[2]['word'] = $day_word.'注册男 / 女数';
        $infos[2]['values'] = "男 {$drzcboyyh} 人 / 女 {$drzcgirlyh} 人";
        $infos[2]['color'] = "red";

        //昨日注册男/女数
        $zrzcboyyh_where = "me_sex = 1 and me_add_time >= $last_start_time and me_add_time <= $last_end_time".$wheres;
        $zrzcboyyh = Db::table('fa_member')->where($zrzcboyyh_where)->count('member_id');
        $zrzcgirlyh_where = "me_sex = 2 and me_add_time >= $last_start_time and me_add_time <= $last_end_time".$wheres;
        $zrzcgirlyh = Db::table('fa_member')->where($zrzcgirlyh_where)->count('member_id');
        $infos[3]['word'] = $last_day_word.'注册男 / 女数';
        $infos[3]['values'] = "男 {$zrzcboyyh} 人 / 女 {$zrzcgirlyh} 人";
        $infos[3]['color'] = "red";

        //当日注册男用户充值金额/人数
        $drczje_where = "a.me_add_time >= $start_time and a.me_add_time <= $end_time and b.add_time >= $start_time and b.add_time <= $end_time".$wherea;
        $drczje = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($drczje_where)
            ->sum('b.pay_money');
        $drczrs_where = "a.me_add_time >= $start_time and a.me_add_time <= $end_time and b.add_time >= $start_time and b.add_time <= $end_time".$wherea;
        $drczrs = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($drczrs_where)
            ->group('b.member_id')
            ->count('a.member_id');
        $infos[4]['word'] = $day_word.'注册男用户充值金额 / 人数';
        $infos[4]['values'] = "{$drczje} 元 / {$drczrs} 人";
        $infos[4]['color'] = "blue";

        //昨日注册男用户充值金额/人数
        $zrczje_where = "a.me_add_time >= $last_start_time and a.me_add_time <= $last_end_time and b.add_time >= $last_start_time and b.add_time <= $last_end_time".$wherea;
        $zrczje = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($zrczje_where)
            ->sum('b.pay_money');
        $zrczrs_where = "a.me_add_time >= $last_start_time and a.me_add_time <= $last_end_time and b.add_time >= $last_start_time and b.add_time <= $last_end_time".$wherea;
        $zrczrs = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($zrczrs_where)
            ->group('b.member_id')
            ->count('a.member_id');
        $infos[5]['word'] = $last_day_word.'注册男用户充值金额 / 人数';
        $infos[5]['values'] = "{$zrczje} 元 / {$zrczrs} 人";
        $infos[5]['color'] = "blue";

        //当日老男用户（3天前注册）充值金额/人数
        $start_time_old = $start_time - 86400 * 3;//三天前
        $end_time_old = $end_time - 86400 * 3;//三天前
        $lyhczje_where = "a.me_add_time >= $start_time_old and a.me_add_time <= $end_time_old and b.add_time >= $start_time and b.add_time <= $end_time".$wherea;
        $lyhczje = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($lyhczje_where)
            ->sum('b.pay_money');
        $lyhczrs_where = "a.me_add_time >= $start_time_old and a.me_add_time <= $end_time_old and b.add_time >= $start_time and b.add_time <= $end_time".$wherea;
        $lyhczrs = Db::table('fa_member')
            ->alias('a')
            ->join('fa_recharge_stamp_order b', 'a.member_id = b.member_id')
            ->where($lyhczrs_where)
            ->group('b.member_id')
            ->count('a.member_id');
        $infos[6]['word'] = '老男用户（3天前注册） '.$day_word.'充值金额 / 人数';
        $infos[6]['values'] = "{$lyhczje} 元 / {$lyhczrs} 人";
        $infos[6]['color'] = "#b36d41";

        //当日活跃男/女
        $rhyboy = Db::table('fa_member')
            ->where("me_sex = 1".$wheres)  // 筛选渠道为抖音的男用户
            ->whereBetween('me_add_time', [$start_time, $end_time])  // 用户注册时间为当天
            ->whereExists(function ($query) use ($start_time_hm,$end_time_hm) {
                $query->table('fa_rong_msg')
                    ->whereColumn('fa_rong_msg.fromUserId', 'fa_member.member_id')  // 关联用户
                    ->whereBetween('timestamp', [$start_time_hm, $end_time_hm])  // 消息发送时间为当天
                    ->group('fromUserId, toUserId')
                    ->having('COUNT(*) >= 2');
            })
            ->count();
        $rhygirl = Db::table('fa_member')
            ->where("me_sex = 2".$wheres)  // 筛选渠道为抖音的女用户
            ->whereBetween('me_add_time', [$start_time, $end_time])  // 用户注册时间为当天
            ->whereExists(function ($query) use ($start_time_hm,$end_time_hm) {
                $query->table('fa_rong_msg')
                    ->whereColumn('fa_rong_msg.fromUserId', 'fa_member.member_id')  // 关联用户
                    ->whereBetween('timestamp', [$start_time_hm, $end_time_hm])  // 消息发送时间为当天
                    ->group('fromUserId, toUserId')
                    ->having('COUNT(*) >= 2');
            })
            ->count();
        $infos[7]['word'] = $day_word.'活跃男 / 女';
        $infos[7]['values'] = "{$rhyboy} 人 / {$rhygirl} 人";
        $infos[7]['color'] = "brown";

        //昨日活跃男/女
        $zrhyboy = Db::table('fa_member')
            ->where("me_sex = 1".$wheres)  // 筛选渠道为抖音的男用户
            ->whereBetween('me_add_time', [$last_start_time, $last_end_time])  // 用户注册时间为当天
            ->whereExists(function ($query) use ($last_start_time_hm,$last_end_time_hm) {
                $query->table('fa_rong_msg')
                    ->whereColumn('fa_rong_msg.fromUserId', 'fa_member.member_id')  // 关联用户
                    ->whereBetween('timestamp', [$last_start_time_hm, $last_end_time_hm])  // 消息发送时间为当天
                    ->group('fromUserId, toUserId')
                    ->having('COUNT(*) >= 2');
            })
            ->count();
        $zrhygirl = Db::table('fa_member')
            ->where("me_sex = 2".$wheres)  // 筛选渠道为抖音的女用户
            ->whereBetween('me_add_time', [$last_start_time, $last_end_time])  // 用户注册时间为当天
            ->whereExists(function ($query) use ($last_start_time_hm,$last_end_time_hm) {
                $query->table('fa_rong_msg')
                    ->whereColumn('fa_rong_msg.fromUserId', 'fa_member.member_id')  // 关联用户
                    ->whereBetween('timestamp', [$last_start_time_hm, $last_end_time_hm])  // 消息发送时间为当天
                    ->group('fromUserId, toUserId')
                    ->having('COUNT(*) >= 2');
            })
            ->count();
        $infos[8]['word'] = $last_day_word.'活跃男 / 女';
        $infos[8]['values'] = "{$zrhyboy} 人 / {$zrhygirl} 人";
        $infos[8]['color'] = "brown";

        //当日 女免费文字收益
        $girlMfSy = Db::table('fa_finance')->where("add_time >= $start_time and add_time <= $end_time and g_id = -88 and status = 1")->sum('money');
        $girlMfSyAll = Db::table('fa_finance')->where("g_id = -88 and status = 1")->sum('money');
        $girlMfSy = round($girlMfSy, 2);
        $girlMfSyAll = round($girlMfSyAll, 2);
//        $infos[9]['word'] = $day_word.'女免费文字收益';
//        $infos[9]['values'] = "{$girlMfSy} 元 / 总 {$girlMfSyAll} 元";
//        $infos[9]['color'] = "#008792";
        $mfwzArr = ['word'=>$day_word.'女免费文字收益','values'=>"{$girlMfSy} 元 / 总 {$girlMfSyAll} 元",'color'=>'#008792','start_time'=>$start_time,'end_time'=>$end_time];

        //当日 女视频体验卷收益
        $girlTyjSy = Db::table('fa_finance')->where("add_time >= $start_time and add_time <= $end_time and g_id = -99 and status = 1")->sum('money');
        $girlTyjSyAll = Db::table('fa_finance')->where("g_id = -99 and status = 1")->sum('money');
        $girlTyjSy = round($girlTyjSy, 2);
        $girlTyjSyAll = round($girlTyjSyAll, 2);
//        $infos[10]['word'] = $day_word.'女视频体验卷收益';
//        $infos[10]['values'] = "{$girlTyjSy} 元 / 总 {$girlTyjSyAll} 元";
//        $infos[10]['color'] = "#008792";
        $tyjsyArr = ['word'=>$day_word.'女视频体验卷收益','values'=>"{$girlTyjSy} 元 / 总 {$girlTyjSyAll} 元",'color'=>'#008792','start_time'=>$start_time,'end_time'=>$end_time];


        //当日收益
        $drsyArr = Db::table('fa_member')
            ->alias('a')
            ->field("a.member_id,
                            (select SUM(f.money) from fa_finance f where f.member_id = a.member_id and f.add_time >= $start_time and f.add_time <= $end_time and
    
                            ((f.type in(4,5,6,13) and f.status = 1 and f.money_type = 2 and f.g_id not in(-88,-99,-111) and f.rebate_type = 0) or
                            (f.type = 11 and f.status = 1 and f.money_type = 2 and f.chat_type = 0 and f.rebate_type = 1))
    
                            ) as sy_money
                        ")
            ->where("a.me_sex =2 and a.me_status = 1")
            ->having("sy_money is not null")
            ->order("sy_money desc")
            ->select();
        $drsy = [['word'=>$day_word.'收益100以上人数','values'=>0,'color'=>'#FF00FF6','min'=>100,'max'=>99999999,'start_time'=>$start_time,'end_time'=>$end_time],
                 ['word'=>$day_word.'收益50-99人数','values'=>0,'color'=>'#FF00FF6','min'=>50,'max'=>99,'start_time'=>$start_time,'end_time'=>$end_time],
                 ['word'=>$day_word.'收益20-49人数','values'=>0,'color'=>'#FF00FF6','min'=>20,'max'=>50,'start_time'=>$start_time,'end_time'=>$end_time],
                 ['word'=>$day_word.'收益5-19人数','values'=>0,'color'=>'#FF00FF6','min'=>5,'max'=>20,'start_time'=>$start_time,'end_time'=>$end_time],
                 ['word'=>$day_word.'收益5元以下人数','values'=>0,'color'=>'#FF00FF6','min'=>0,'max'=>5,'start_time'=>$start_time,'end_time'=>$end_time],
                ];
        if(!empty($drsyArr)){
            foreach ($drsyArr as $k=>$v){
                foreach ($drsy as $kk=>$vv){
                    if($vv['min'] <= $v['sy_money'] && $v['sy_money'] < $vv['max']){
                        //符合
                        $drsy[$kk]['values'] ++;
                        break;
                    }
                }
            }
        }


        //昨日收益
        $zrsyArr = Db::table('fa_member')
            ->alias('a')
            ->field("a.member_id,
                            (select SUM(f.money) from fa_finance f where f.member_id = a.member_id and f.add_time >= $last_start_time and f.add_time <= $last_end_time and
    
                            ((f.type in(4,5,6,13) and f.status = 1 and f.money_type = 2 and f.g_id not in(-88,-99,-111) and f.rebate_type = 0) or
                            (f.type = 11 and f.status = 1 and f.money_type = 2 and f.chat_type = 0 and f.rebate_type = 1))
    
                            ) as sy_money
                        ")
            ->where("a.me_sex =2 and a.me_status = 1")
            ->having("sy_money is not null")
            ->order("sy_money desc")
            ->select();
        $zrsy = [['word'=>$last_day_word.'收益100以上人数','values'=>0,'color'=>'#FF00FF6','min'=>100,'max'=>99999999,'start_time'=>$last_start_time,'end_time'=>$last_end_time],
                ['word'=>$last_day_word.'收益50-99人数','values'=>0,'color'=>'#FF00FF6','min'=>50,'max'=>99,'start_time'=>$last_start_time,'end_time'=>$last_end_time],
                ['word'=>$last_day_word.'收益20-49人数','values'=>0,'color'=>'#FF00FF6','min'=>20,'max'=>50,'start_time'=>$last_start_time,'end_time'=>$last_end_time],
                ['word'=>$last_day_word.'收益5-19人数','values'=>0,'color'=>'#FF00FF6','min'=>5,'max'=>20,'start_time'=>$last_start_time,'end_time'=>$last_end_time],
                ['word'=>$last_day_word.'收益5元以下人数','values'=>0,'color'=>'#FF00FF6','min'=>0,'max'=>5,'start_time'=>$last_start_time,'end_time'=>$last_end_time],
                ];
        if(!empty($zrsyArr)){
            foreach ($zrsyArr as $k=>$v){
                foreach ($zrsy as $kk=>$vv){
                    if($vv['min'] <= $v['sy_money'] && $v['sy_money'] < $vv['max']){
                        //符合
                        $zrsy[$kk]['values'] ++;
                        break;
                    }
                }
            }
        }

        return ['infos'=>$infos,'drsy'=>$drsy,'zrsy'=>$zrsy,'mfwzArr'=>$mfwzArr,'tyjsyArr'=>$tyjsyArr];
    }


    /**
     * 查询符合收益的女孩列表
     * User:@hang
     */
    public function getsygirllist(Request $request)
    {
        $id = input('id');//筛选条件
        $arr = explode('#',$id);
        $min = $arr[0];
        $max = $arr[1];
        $start_time = $arr[2];
        $end_time = $arr[3];

        $param = $request->param();
        $whehe = [];
        if (isset($param['member_id']) && !empty($param['member_id'])) {
            $whehe[] = ['a.member_id','=',$param['member_id']];
        }

        $buildSql = Db::table('fa_member')
            ->alias('a')
            ->join("fa_member d",'d.member_id = a.me_parent','LEFT')
            ->field("a.member_id,a.me_phone,a.me_add_time,a.me_nick_name,a.me_img,a.me_parent,a.me_zx,d.member_id as fmember_id,d.me_uid as fme_uid,d.me_nick_name as fme_nick_name,
                            (select SUM(f.money) from fa_finance f where f.member_id = a.member_id and f.add_time >= $start_time and f.add_time <= $end_time and
    
                            ((f.type in(4,5,6,13) and f.status = 1 and f.money_type = 2 and f.g_id not in(-88,-99,-111) and f.rebate_type = 0) or
                            (f.type = 11 and f.status = 1 and f.money_type = 2 and f.chat_type = 0 and f.rebate_type = 1))
    
                            ) as sy_money
                        ")
            ->where("a.me_sex =2 and a.me_status = 1")
            ->where($whehe)
            ->having("sy_money >= $min and sy_money < $max")
            ->buildSql();

        $data = Db::table($buildSql)
            ->alias('cx')
            ->order("cx.sy_money desc")
            ->paginate($this->admin['per_page'],false,['query'=>request()->param()]);


        $adminid = $this->uid;
        $data->each(function ($v, $k)use($id,$adminid) {
            //只有超管能看全部手机号
            if($adminid != 1){
                $v['me_phone'] = hide_phone_number($v['me_phone']);
            }
            if(empty($v['me_parent'])){
                $v['me_parent_word'] = '无上级';
            }else{
                //查询父级用户信息
                $finfoUid = !empty($v['fmember_id'])?'('.$v['fme_nick_name'].')':'-';
                $v['me_parent_word'] = $v['me_parent'].$finfoUid;
            }
            switch($v['me_zx']){
                case '0': $v['me_zx_word'] = '在线';break;
                case '1': $v['me_zx_word'] = '离线';break;
            }
            $v['me_add_time'] = date('m-d H:i',$v['me_add_time']);
            return $v;
        });

        //关键词，排序等赋值
        $this->assign($request->get());
        $this->assign([
            'data'  => $data,
            'page'  => $data->render(),
            'total' => $data->total(),
            'id' => $id,
        ]);
        return $this->fetch();
    }


    /**
     * 查询女免费文字收益的女孩列表
     * User:@hang
     */
    public function getgirlmfwzlist(Request $request)
    {
        $id = input('id');//筛选条件
        $arr = explode('#',$id);
        $start_time = $arr[0];
        $end_time = $arr[1];

        $param = $request->param();
        $whehe = [];
        if (isset($param['member_id']) && !empty($param['member_id'])) {
            $whehe[] = ['a.member_id','=',$param['member_id']];
        }

        $buildSql = Db::table('fa_finance')
            ->alias('a')
            ->join("fa_member b",'a.member_id = b.member_id','LEFT')
            ->join("fa_member c",'b.me_parent = c.member_id','LEFT')
            ->field("b.member_id,b.me_phone,b.me_add_time,b.me_nick_name,b.me_img,b.me_parent,b.me_zx,c.member_id as fmember_id,c.me_uid as fme_uid,c.me_nick_name as fme_nick_name,
                            (select SUM(f.money) from fa_finance f where f.member_id = a.member_id and f.add_time >= $start_time and f.add_time <= $end_time and f.g_id = -88 and f.status = 1) as sy_mfwz_money
                            
                        ")
            ->where("a.add_time >= $start_time and a.add_time <= $end_time and a.g_id = -88 and a.status = 1")
            ->group('a.member_id')
            ->where($whehe)
            ->buildSql();

        $data = Db::table($buildSql)
            ->alias('cx')
            ->order("cx.sy_mfwz_money desc")
            ->paginate($this->admin['per_page'],false,['query'=>request()->param()]);

        $adminid = $this->uid;
        $data->each(function ($v, $k)use($id,$adminid) {
            //只有超管能看全部手机号
            if($adminid != 1){
                $v['me_phone'] = hide_phone_number($v['me_phone']);
            }
            if(empty($v['me_parent'])){
                $v['me_parent_word'] = '无上级';
            }else{
                //查询父级用户信息
                $finfoUid = !empty($v['fmember_id'])?'('.$v['fme_nick_name'].')':'-';
                $v['me_parent_word'] = $v['me_parent'].$finfoUid;
            }
            switch($v['me_zx']){
                case '0': $v['me_zx_word'] = '在线';break;
                case '1': $v['me_zx_word'] = '离线';break;
            }
            $v['me_add_time'] = date('m-d H:i',$v['me_add_time']);
            $v['sy_mfwz_money'] = round($v['sy_mfwz_money'], 2);
            return $v;
        });

        //关键词，排序等赋值
        $this->assign($request->get());
        $this->assign([
            'data'  => $data,
            'page'  => $data->render(),
            'total' => $data->total(),
            'id' => $id,
        ]);
        return $this->fetch();
    }


    /**
     * 查询女视频体验卷收益的女孩列表
     * User:@hang
     */
    public function getgirlsptyjlist(Request $request)
    {
        $id = input('id');//筛选条件
        $arr = explode('#',$id);
        $start_time = $arr[0];
        $end_time = $arr[1];

        $param = $request->param();
        $whehe = [];
        if (isset($param['member_id']) && !empty($param['member_id'])) {
            $whehe[] = ['a.member_id','=',$param['member_id']];
        }

        $buildSql = Db::table('fa_finance')
            ->alias('a')
            ->join("fa_member b",'a.member_id = b.member_id','LEFT')
            ->join("fa_member c",'b.me_parent = c.member_id','LEFT')
            ->field("b.member_id,b.me_phone,b.me_add_time,b.me_nick_name,b.me_img,b.me_parent,b.me_zx,c.member_id as fmember_id,c.me_uid as fme_uid,c.me_nick_name as fme_nick_name,
                            (select SUM(f.money) from fa_finance f where f.member_id = a.member_id and f.add_time >= $start_time and f.add_time <= $end_time and f.g_id = -99 and f.status = 1) as sy_sptyj_money
                            
                        ")
            ->where("a.add_time >= $start_time and a.add_time <= $end_time and a.g_id = -99 and a.status = 1")
            ->group('a.member_id')
            ->where($whehe)
            ->buildSql();

        $data = Db::table($buildSql)
            ->alias('cx')
            ->order("cx.sy_sptyj_money desc")
            ->paginate($this->admin['per_page'],false,['query'=>request()->param()]);

        $adminid = $this->uid;
        $data->each(function ($v, $k)use($id,$adminid) {
            //只有超管能看全部手机号
            if($adminid != 1){
                $v['me_phone'] = hide_phone_number($v['me_phone']);
            }
            if(empty($v['me_parent'])){
                $v['me_parent_word'] = '无上级';
            }else{
                //查询父级用户信息
                $finfoUid = !empty($v['fmember_id'])?'('.$v['fme_nick_name'].')':'-';
                $v['me_parent_word'] = $v['me_parent'].$finfoUid;
            }
            switch($v['me_zx']){
                case '0': $v['me_zx_word'] = '在线';break;
                case '1': $v['me_zx_word'] = '离线';break;
            }
            $v['me_add_time'] = date('m-d H:i',$v['me_add_time']);
            $v['sy_sptyj_money'] = round($v['sy_sptyj_money'], 2);
            return $v;
        });

        //关键词，排序等赋值
        $this->assign($request->get());
        $this->assign([
            'data'  => $data,
            'page'  => $data->render(),
            'total' => $data->total(),
            'id' => $id,
        ]);
        return $this->fetch();
    }

}
